<form action="index.php/opportunity/update/" method="post" name="myform" id="myform"  onSubmit="return check()">
<div id="inline1">
<h2><span>销售机会信息</span></h2>
<table>
        <tr><th colspan="5">机会：</th></tr>
        <tr>
        	<td class="name" width="80"><span>*</span>机会主题：</td>
            <td colspan="4"><input name="subject" style=" width:427px;" type="text" class="text_width" id="subject" value=<?= $update_sales->subject?>></input></td>
        </tr>
        <tr>
            <td class="name" width="80"><span>*</span>客户：</td>
            <td colspan="4"><input id="customer_name" class="text_width" autocomplete="off" style=" width:427px;" type="text" name="customer_name" value=<?= $customer_name?>></input></td></td>
        </tr>
        <tr>
        	<td class="name" width="80" style="padding-left:0px;"><span>*</span>客户联系人：</td>
            <td width="170" colspan="4">
				<select id="contacter_name" name="contacter_id" style="width:427px;">
						<option value="<?= $update_sales->contacter_id?>"><?= $update_sales->name?></option>
                </select>
            </td>
        </tr>
        <tr>
            <td class="name" width="80">状态：</td>
            <td width="170" colspan="5">
            	<select name="status">
                    <option value="跟踪" <?php if($update_sales->status == '跟踪'):?>selected="selected"<?php endif;?> >跟踪</option>
                    <option value="成功" <?php if($update_sales->status == '成功'):?>selected="selected"<?php endif;?>>成功</option>
                    <option value="失败" <?php if($update_sales->status == '失败'):?>selected="selected"<?php endif;?>>失败</option>
                    <option value="搁置" <?php if($update_sales->status == '搁置'):?>selected="selected"<?php endif;?>>搁置</option>
                    <option value="失效" <?php if($update_sales->status == '失效'):?>selected="selected"<?php endif;?>>失效</option>
                </select>
            </td>
        </tr>
        <tr><th colspan="5">基本情况：</th></tr>
        <tr>
            <td class="name" width="80">发现时间：</td>
             <?php
	        $find_time = '';
	         if($update_sales->find_time != '0000-00-00 00:00:00'){
	         	$find_time = substr ( $update_sales->find_time, 0, 10 );
	         }
        ?>
            <td width="170"><input name="find_time" type="text" class="datepicker" id="find_time"  style="background:url(images/calendar.gif) right 1px no-repeat;" value=<?= $find_time?> ></input></td>
            <td>&nbsp;</td>
            <td class="name" width="80">来源：</td>
            <td width="170"><input name="source" type="text" id="source" value=<?= $update_sales->source?>></input></td>
        </tr>
        <tr>
            <td class="name" width="80">负责人：</td>
            <td width="170"><input name="principal" type="text" id="principal" value=<?= $update_sales->principal?> ></input></td>
            <td>&nbsp;</td>
            <td class="name" width="80">提供人：</td>
            <td width="170"><input name="provider" type="text" id="provider" value=<?= $update_sales->provider?> ></input></td>
        </tr>
        <tr>
            <td class="gj_name" width="80">客户需求：</td>
            <td colspan="4"><textarea name="customer_demand" ><?= $update_sales->customer_demand?></textarea></td>
        </tr>
        <tr><th colspan="5">预期：</th></tr>
        <tr>
            <td class="name" width="80">预计签单<br />日期：</td>
            <td width="170">
            <?php
	        $expectedsigningdate = '';
	         if($update_sales->expected_signing_date != '0000-00-00 00:00:00'){
	         	$expectedsigningdate = substr ( $update_sales->expected_signing_date, 0, 10 );
	         }
        ?>
            <input name="expected_signing_date" type="text"  style="background:url(images/calendar.gif) right 1px no-repeat;" id="expected_signing_date" class="datepicker" value=<?= $expectedsigningdate?> ></input></td>
            <td>&nbsp;</td>
            <td class="name" width="85">预期金额：</td>
            <?php
            $expected_amount = '';
            if($update_sales->expected_amount){
            	$expected_amount = $update_sales->expected_amount;
            }?>
            <td width="170"><input class="input_bg" name="expected_amount" type="text" id="expected_amount" value=<?= $expected_amount?> ></input></td>
        </tr>
        <tr><th colspan="5">当前状态：</th></tr>
        <tr>
            <td class="name" width="80">阶段：</td>
            <td width="170">
            	<select name="stage">
                    <option value="沟通" <?php if($update_sales->stage == '沟通'):?>selected="selected"<?php endif;?>>沟通</option>
                    <option value="立项" <?php if($update_sales->stage == '立项'):?>selected="selected"<?php endif;?>>立项</option>
                    <option value="招投标/谈判" <?php if($update_sales->stage == '招投标/谈判'):?>selected="selected"<?php endif;?>>招投标/谈判</option>
                    <option value="签合同" <?php if($update_sales->stage == '签合同'):?>selected="selected"<?php endif;?>>签合同</option>
                </select>
            </td>
            <td>&nbsp;</td>
            <td class="name" width="80">可能性：</td>
            <td width="170">
            	<select name="possibility">
                    <option value="0" <?php if($update_sales->possibility == '0'):?>selected="selected"<?php endif;?>>00%</option>
                    <option value="10" <?php if($update_sales->possibility == '10'):?>selected="selected"<?php endif;?>>10%</option>
                    <option value="20" <?php if($update_sales->possibility == '20'):?>selected="selected"<?php endif;?>>20%</option>
                    <option value="30" <?php if($update_sales->possibility == '30'):?>selected="selected"<?php endif;?>>30%</option>
                    <option value="40" <?php if($update_sales->possibility == '40'):?>selected="selected"<?php endif;?>>40%</option>
                    <option value="50" <?php if($update_sales->possibility == '50'):?>selected="selected"<?php endif;?>>50%</option>
                    <option value="60" <?php if($update_sales->possibility == '60'):?>selected="selected"<?php endif;?>>60%</option>
                    <option value="70" <?php if($update_sales->possibility == '70'):?>selected="selected"<?php endif;?>>70%</option>
                    <option value="80" <?php if($update_sales->possibility == '80'):?>selected="selected"<?php endif;?>>80%</option>
                    <option value="90" <?php if($update_sales->possibility == '90'):?>selected="selected"<?php endif;?>>90%</option>
                    <option value="100" <?php if($update_sales->possibility == '100'):?>selected="selected"<?php endif;?>>100%</option>
                </select>
            </td>
        </tr>

        <tr>
            <td class="gj_name" width="80">阶段备注：</td>
            <td colspan="4"><textarea name="stage_remark" value=<?= $update_sales->stage_remark?>></textarea></td>
        </tr>
        <tr><th colspan="5">机会阶段推进历史：</th></tr>
        <?php foreach($opportunity_stages as $opportunity_stage):?>
        <tr>
        	<?php $time = substr ( $opportunity_stage->update_time, 0, 10 );?>
        	<?php
			 $possibility="";
			 if($opportunity_stage->possibility){
			 	$possibility="("."$opportunity_stage->possibility"."%)";
			 }
			 ?>
            <td colspan="5">
	            <span class="span_right">日期：<?= $time?></span>
	            <span class="span_right">状态：<?= $opportunity_stage->stage?><?= $possibility?></span>
	            <span class="span_right">用户：<?= $opportunity_stage->user_name?></span>
            </td>
        </tr>
        <tr>
            <td valign="top" colspan="5">阶段备注：<?= $opportunity_stage->remark?></td>
        </tr>
        <tr><td style=" height:10px; line-height:10px;">&nbsp;</td></tr>
        <?php endforeach;?>
        <tr><td colspan="5">&nbsp;</td></tr>
        <tr class="sub">
            <td colspan="5"><input type="submit" value="提交" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="重置" /></td>
        </tr>
    </table>
</div>
<input type="hidden" name="id" value=<?= $update_sales->id?> >  <!-- 销售机会编号 -->
<input type="hidden" name="histage" value=<?= $update_sales->stage?> >  <!-- 阶段 -->
<input type="hidden" id="type" value="0" ></input>
</form>
<script type="text/javascript">

$(function() {
		$( ".datepicker" ).datepicker();
});

	function check(){
		var error="";
		var subject=$.trim(document.getElementsByName("subject")[0].value);
		var customer_name=$.trim(document.getElementsByName("customer_name")[0].value);
		if(subject == ""){
			 error="错误：\x0d";
             error+="机会主题不允许为空,请填写\x0d";
             document.myform.subject.focus();
	    }
		if(customer_name == ""){
			 error="错误：\x0d";
             error+="客户名称不允许为空,请填写\x0d";
             document.myform.customer_name.focus();
	    }

        if(error != ""){
        	alert(error);
    		return false;
        }else{
            return true;
        }
	}
</script>